<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Application Security Scan Report for {{ target_domain }}</title>

    {% for css in ['bootstrap-3.3.2.min.css'] %}
        <style>
            {% include css %}
        </style>
    {% endfor %}

    <style>
        .table {
            table-layout:fixed;
        }

        .table tbody tr td {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding: 2px;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="thumbnail">
            <div class="row">
                <div class="col-md-12">
                    <h1>
                        <p class="text-center">Application Security Scan for {{ target_domain }}</p>
                    </h1>
                </div>
            </div>
            <div class="row">
                <div class="col-md-1"></div>
                <div class="col-md-4">
                    <h4>Meta-data</h4>
                    <p>This report contains the application security scan results
                    for the w3af scan of the {{ target_domain }} which finished
                    {{ get_current_date() }}</p>
                </div>

                <div class="col-md-3">
                    <h4>Configured target URLs</h4>
                    <ul>
                    {% for target_urls in target_urls %}
                        <li> {{ target_urls }} </li>
                    {% endfor %}
                    </ul>
                </div>

                <div class="col-md-3">
                    <h4>Enabled plugins</h4>
                    <ul>
                    {% for plugin_type in enabled_plugins %}
                        <li> <h5>{{ plugin_type }}</h5>
                            <ul>
                            {% for plugin_name in enabled_plugins[plugin_type] %}
                                <li>{{ plugin_name }}</li>
                            {% endfor %}
                            </ul>
                        </li>
                    {% endfor %}
                    </ul>
                </div>
                <div class="col-md-1"></div>
            </div>
        </div>
    {% for finding in findings %}
        <div class="thumbnail">
            <div class="row">
                <div class="col-md-2"><img src="{{ finding.get_severity()|severity_icon }}" /></div>
                <div class="col-md-8"><h2 class="text-center">{{ finding.get_name() }}</h2></div>
                <div class="col-md-2"><b>{{ finding.get_severity()|severity_text|safe }}</b></div>
            </div>
            <div class="row">
                <div class="col-md-1"></div>
                <div class="col-md-10">
                    <h4>Summary</h4>
                    <p>{{ finding.get_desc() }}</p>

                    {% if finding.has_db_details() == True %}
                        <br />
                        <h4>Description</h4>
                        {{ finding.get_long_description()|render_markdown|safe }}
                    {% endif %}
                </div>
                <div class="col-md-1"></div>
            </div>
            <div class="row">
                <div class="col-md-1"></div>
                <div class="col-md-10">
                    <ul>
                    {% if finding.get_url() != None %}
                        <li>Vulnerable URL: <a href="{{ finding.get_url() }}">{{ finding.get_url() }}</a></li>
                    {% endif %}

                    {% if finding.get_token_name() != None %}
                        <li>Vulnerable Parameter: <code>{{ finding.get_token_name() }}</code></li>
                    {% endif %}
                    </ul>
                </div>
                <div class="col-md-1"></div>
            </div>

            {% if finding.has_db_details() %}
            <div class="row">
                <div class="col-md-1"></div>
                <div class="col-md-10">
                    <h4>Fix</h4>
                    {{ finding.get_fix_guidance()|render_markdown|safe }}

                    {% if finding.get_references() %}
                        <h4>References</h4>
                        <ul>
                        {% for ref in finding.get_references() %}
                            <li> <a href="{{ ref.url }}">{{ ref.title }}</a></li>
                        {% endfor %}
                        </ul>
                    {% endif %}
                </div>
                <div class="col-md-1"></div>
            </div>
            {% endif %}

            {% if finding.get_id() %}

                <div class="row">
                    <div class="col-md-1"></div>
                    <div class="col-md-10"><h4>HTTP proof</h4></div>
                    <div class="col-md-1"></div>
                </div>

                {% for id in finding.get_id() %}
                    <div class="row">
                        <div class="col-md-2"></div>
                        <div class="col-md-8">
                            <pre>{{ id|request }}</pre>
                        </div>
                        <div class="col-md-2"></div>
                    </div>
                    <div class="row">
                        <div class="col-md-2"></div>
                        <div class="col-md-8">
                            <pre>{{ id|response }}</pre>
                        </div>
                        <div class="col-md-2"></div>
                    </div>
                {% endfor %}
            {% endif %}
        </div>
    {% endfor %}

    <div class="thumbnail">
        <div class="row">
            <div class="col-md-12">
                <h3>
                    <p class="text-center">URLs found during application scan</p>
                </h3>
            </div>
        </div>
        <div class="row">
            <div class="col-md-2"></div>
            <div class="col-md-8">
                <ul>
                    {% for url in known_urls %}
                        <li><a href="{{ url }}">{{ url }}</a></li>
                    {% endfor %}
                </ul>
            </div>
            <div class="col-md-2"></div>
        </div>
    </div>

    {% if debug_log %}
    <div class="thumbnail">
        <div class="row">
            <div class="col-md-12">
                <h3>
                    <p class="text-center">Scan log</p>
                </h3>
            </div>
        </div>
        <div class="row">
            <div class="col-md-1"></div>
            <div class="col-md-10">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th width="20%">Timestamp</th>
                            <th width="10%">Log level</th>
                            <th width="70%">Message</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for timestamp, level, message in debug_log %}
                            {% if level == 'error' %}
                                <tr class="danger">
                            {% else %}
                                <tr>
                            {% endif %}
                                    <td>{{ timestamp }}</td>
                                    <td>{{ level }}</td>
                                    <td>{{ message }}</td>
                                </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            <div class="col-md-1"></div>
        </div>
    </div>
    {% endif %}

    </div>
</body>

</html>